#include <stdio.h>

void print(int n, char nums[n])
{
    for (size_t i = 6; i < 14; i++)
    {
        printf("%d", nums[i] - '0');
    }
}

int main(int argc, char *argv[])
{

    char idCard[18];
    int wi[] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1};
    char lastNums[] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
    int sum = 0, i = 0;

    gets(idCard);

    for (i = 0; i < 17; i++)
    {
        sum += (int)(idCard[i] - '0') * wi[i];
    }

    int lastNum = sum % 11;

    if (idCard[17] == lastNums[lastNum])
    {
        print(18, idCard);
    }
    else
    {
        printf("Fail");
    }

    return 0;
}